<template>
  <div>
    <van-uploader
      v-model="fileList"
      :after-read="afterRead"
      accept="image/*"
      name="file"
    />
    <van-button
      type="primary"
      @click="btn"
    >上传</van-button>
  </div>
</template>

<script>
export default {
  name: "shangchaun",
  data() {
    return {
      fileList: [],
    };
  },
  methods: {
    btn() {
      let file = this.fileList[0].file;
      let param = new FormData();
      param.append("file", file);
      let config = {
        headers: { "Content-Type":"multipart/form-data"},
      };
      this.axios
        .post("apis/kuan_api/sendmessage.php", param, config)
        .then((res) => {
          console.log(res);
        })
        .catch((err) => {
          console.error(err);
        });
    },
    afterRead() {
      console.log(this.fileList);
    },
  },
};
</script>

<style scoped>
</style>